<template>
	<view>
		<view class="lb-main-32">
			<view class="lb-box" v-for="(item,index) in listData" :key="index">
				<view class="top">
					<view class="title">
						{{item.title}}
					</view>
					<view class="time">
						{{item.createtime}}
					</view>
				</view>
				<view class="foot">
					<text>
						{{item.message}}
					</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getMsgApiList
	} from "@/api/apis/comm.js"
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				listData: []
			}
		},
		onReachBottom() {
			//注意 这里是重要的一步，不满足条件下拉加载不能继续请求数据
			if (!this.isLoading) {
				this.getList();
			}

		},
		onLoad(options) {
			this.getList()
		},
		methods: {
			getList() {
				uni.showLoading({
					title: "加载中",
					mask: true
				});
				getMsgApiList({
					page: this.page,
					limit: this.limit
				}).then(res => {
					uni.hideLoading();
					if (this.page == 1) {
						this.listData = res.data.data;
					} else {
						this.listData = this.listData.concat(res.data.data);
					}
					if (res.data.total >= this.page * this.limit) {
						//请求成功 节流阀 设置为false（没有走完函数不允许再次请求）
						this.isLoading = false;
						this.page++;
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.lb-box {
		background: rgba(255, 255, 255, 1);
		box-shadow: 0rpx 2rpx 4rpx rgba(0, 0, 0, 0.16);
		border-radius: 16rpx;
		padding: 30rpx 0;
		margin-bottom: 30rpx;

		.top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 24rpx 24rpx;

			.title {
				font-size: $main-font-28;
				font-weight: bold;
				color: #4F4F4F;
			}

			.time {
				font-size: $main-font-24;
				color: $main-font-color-grey9;
			}

		}

		.foot {
			border-top: 2rpx solid #F5F5F5;
			padding: 24rpx 24rpx 0;

			text {
				font-size: $main-font-28;
				line-height: 40rpx;
				color: #4F4F4F;
			}
		}
	}
</style>